import React, { Suspense } from 'react'
import { Routes, Route, Navigate } from 'react-router-dom'
import Layout from './pages/Layout'
import Login from './pages/Login'
import NotFound from './pages/NotFound'
import routes from './routes'
export default function App() {
  return (
    <Suspense fallback={
      <div>加载中...</div>
    }>
    <Routes>
      <Route path="/" element={<Layout/>}>
        {
          routes.map(route => (
            <Route key={route.path} path={route.path} element={<route.element/>}/>
          ))
        }
        <Route path="/" element={<Navigate to="/dashBoard"/>}/>
      </Route>
      <Route path="/login" element={<Login/>}/>
      <Route path="*" element={<NotFound/>}/>
    </Routes>
    </Suspense>
  )
}
